package com.usian.admin.controller;

import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.SensitiveControllerApi;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理", tags = "sensitive", description = "敏感词管理API")
public class AdSensitiveController implements SensitiveControllerApi {
    @Autowired
    private AdSensitiveService adSensitiveService;

    @Override
    @PostMapping("/list")
    @ApiOperation(value = "查询敏感词信息", notes = "根据名称分页查询敏感词列表")
    @ApiImplicitParam(name = "dto", type = "SensitiveDto", value = "敏感词名称")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        return adSensitiveService.list(dto);
    }

    @Override
    @PostMapping("/save")
    @ApiOperation(value = "插入敏感词信息", notes = "插入敏感词信息")
    @ApiImplicitParam(name = "adSensitive", type = "AdSensitive", value = "插入敏感词的各个字段")
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改敏感词信息", notes = "修改敏感词信息")
    @ApiImplicitParam(name = "adSensitive", type = "AdSensitive", value = "修改敏感词的各个字段")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    @Override
    @DeleteMapping("/del/{id}")
    @ApiOperation(value = "删除敏感词信息", notes = "删除敏感词信息")
    @ApiParam(name = "id", type = "Integer", value = "删除数据")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteById(id);
    }
}
